package org.javaboy.vhr.controller.emp;

import org.javaboy.vhr.model.Employee;
import org.javaboy.vhr.model.Evaluation;
import org.javaboy.vhr.model.RespBean;
import org.javaboy.vhr.model.RespPageBean;
import org.javaboy.vhr.service.EvaluationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/evaluation")
public class EvaluationController {
    @Autowired
    EvaluationService evaluationService;
    @GetMapping("/")
    public RespPageBean getEvaluationByPage(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer size, Evaluation evaluation, Date[] beginDateScope) {
        return evaluationService.getAllEvaluation(page,size,evaluation,beginDateScope);
    }

    @PostMapping("/add")
    public RespBean addEvaluation(@RequestBody Evaluation evaluation) {
        if (evaluationService.addEvaluation(evaluation) == 1) {
            return RespBean.ok("评价成功!");
        }
        return RespBean.error("添加失败!");
    }

    @PutMapping("/update")
    public RespBean updateByEvaluationId(@RequestBody Evaluation evaluation){
        if(evaluationService.updateByEvaluationId(evaluation) == 1){
            return RespBean.ok("更新成功");
        }
        return RespBean.error("更新失败");
    }
}
